<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 5.2.0">
  <link rel="apple-touch-icon" sizes="180x180" href="/blog/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/blog/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/blog/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/blog/images/logo.svg" color="#222">
  <meta name="baidu-site-verification" content="code-ia4sE56m4l">

<link rel="stylesheet" href="/blog/css/main.css">


<link rel="stylesheet" href="/blog/lib/font-awesome/css/all.min.css">
  
  <link rel="stylesheet" href="/blog/lib/animate-css/animate.min.css">
  <link rel="stylesheet" href="//cdn.jsdelivr.net/npm/@fancyapps/fancybox@3/dist/jquery.fancybox.min.css">

<script class="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"tangmonk-meat.gitee.io","root":"/blog/","scheme":"Muse","version":"8.0.0-rc.4","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12},"copycode":true,"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":true,"mediumzoom":false,"lazyload":true,"pangu":false,"comments":{"style":"tabs","active":"valine","storage":true,"lazyload":true,"nav":null,"activeClass":"valine"},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"fadeInDown","post_body":"fadeInDown","coll_header":"fadeInLeft","sidebar":"fadeInUp"}},"prism":false,"path":"search.xml","localsearch":{"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false}};
  </script>

  <meta name="description" content="1 前言我们都知道 Tomcat 可以部署 war包和静态资源，一般都是放在webapps下面。但是我们还应该知道，有个界面会帮我们去完成这个操作的，当然这个界面一般是不开放的，自己用的时候可以开放出来。">
<meta property="og:type" content="article">
<meta property="og:title" content="配置Tomcat网页管理访问 - Tomcat">
<meta property="og:url" content="https://tangmonk-meat.gitee.io/blog/2021/03/19/%E9%85%8D%E7%BD%AETomcat%E7%BD%91%E9%A1%B5%E7%AE%A1%E7%90%86%E8%AE%BF%E9%97%AE/index.html">
<meta property="og:site_name" content="唐僧肉BLOG">
<meta property="og:description" content="1 前言我们都知道 Tomcat 可以部署 war包和静态资源，一般都是放在webapps下面。但是我们还应该知道，有个界面会帮我们去完成这个操作的，当然这个界面一般是不开放的，自己用的时候可以开放出来。">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://s1.ax1x.com/2020/08/09/aTg3rj.png">
<meta property="og:image" content="https://s1.ax1x.com/2020/08/09/aThxVH.png">
<meta property="og:image" content="https://s1.ax1x.com/2020/08/09/aT7eCd.md.png">
<meta property="og:image" content="https://s1.ax1x.com/2020/08/09/aT7raF.png">
<meta property="article:published_time" content="2021-03-19T13:16:54.926Z">
<meta property="article:modified_time" content="2020-09-23T02:27:09.761Z">
<meta property="article:author" content="TANGMONK-MEAT">
<meta property="article:tag" content="java">
<meta property="article:tag" content="Tomcat">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://s1.ax1x.com/2020/08/09/aTg3rj.png">

<link rel="canonical" href="https://tangmonk-meat.gitee.io/blog/2021/03/19/%E9%85%8D%E7%BD%AETomcat%E7%BD%91%E9%A1%B5%E7%AE%A1%E7%90%86%E8%AE%BF%E9%97%AE/">


<script class="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : false,
    isPost : true,
    lang   : 'zh-CN'
  };
</script>

  <title>配置Tomcat网页管理访问 - Tomcat | 唐僧肉BLOG</title>
  






  <noscript>
  <style>
  body { margin-top: 2rem; }

  .use-motion .menu-item,
  .use-motion .sidebar,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header {
    visibility: visible;
  }

  .use-motion .header,
  .use-motion .site-brand-container .toggle,
  .use-motion .footer { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle,
  .use-motion .custom-logo-image {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line {
    transform: scaleX(1);
  }

  .search-pop-overlay, .sidebar-nav { display: none; }
  .sidebar-panel { display: block; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <main class="main">
      <header class="header" itemscope itemtype="http://schema.org/WPHeader">
        <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/blog/" class="brand" rel="start">
      <i class="logo-line"></i>
      <h1 class="site-title">唐僧肉BLOG</h1>
      <i class="logo-line"></i>
    </a>
      <p class="site-subtitle" itemprop="description">记录生活中的点点滴滴</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
        <i class="fa fa-search fa-fw fa-lg"></i>
    </div>
  </div>
</div>



<nav class="site-nav">
  <ul id="menu" class="main-menu menu">
        <li class="menu-item menu-item-home">

    <a href="/blog/" rel="section"><i class="fa fa-home fa-fw"></i>首页</a>

  </li>
        <li class="menu-item menu-item-about">

    <a href="/blog/about/" rel="section"><i class="fa fa-user fa-fw"></i>关于</a>

  </li>
        <li class="menu-item menu-item-tags">

    <a href="/blog/tags/" rel="section"><i class="fa fa-tags fa-fw"></i>标签<span class="badge">44</span></a>

  </li>
        <li class="menu-item menu-item-categories">

    <a href="/blog/categories/" rel="section"><i class="fa fa-th fa-fw"></i>分类<span class="badge">17</span></a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/blog/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档<span class="badge">38</span></a>

  </li>
      <li class="menu-item menu-item-search">
        <a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
        </a>
      </li>
  </ul>
</nav>



  <div class="search-pop-overlay">
    <div class="popup search-popup">
        <div class="search-header">
  <span class="search-icon">
    <i class="fa fa-search"></i>
  </span>
  <div class="search-input-container">
    <input autocomplete="off" autocapitalize="off" maxlength="80"
           placeholder="搜索..." spellcheck="false"
           type="search" class="search-input">
  </div>
  <span class="popup-btn-close">
    <i class="fa fa-times-circle"></i>
  </span>
</div>
<div id="search-result">
  <div id="no-result">
    <i class="fa fa-spinner fa-pulse fa-5x"></i>
  </div>
</div>

    </div>
  </div>

</div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line"></span>
    <span class="toggle-line"></span>
    <span class="toggle-line"></span>
  </div>

  <aside class="sidebar">

    <div class="sidebar-inner sidebar-nav-active sidebar-toc-active">
      <ul class="sidebar-nav">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <section class="post-toc-wrap sidebar-panel">
          <div class="post-toc animated"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#1-%E5%89%8D%E8%A8%80"><span class="nav-number">1.</span> <span class="nav-text">1 前言</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#2-%E5%A6%82%E4%BD%95%E7%99%BB%E9%99%86%E6%8E%A7%E5%88%B6%E5%8F%B0%EF%BC%9F"><span class="nav-number">2.</span> <span class="nav-text">2 如何登陆控制台？</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#3-%E9%83%A8%E7%BD%B2web%E5%BA%94%E7%94%A8"><span class="nav-number">3.</span> <span class="nav-text">3 部署web应用</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#3-1-%E5%88%A9%E7%94%A8tomcat%E7%9A%84%E8%87%AA%E5%8A%A8%E9%83%A8%E7%BD%B2"><span class="nav-number">3.1.</span> <span class="nav-text">3.1 利用tomcat的自动部署</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#3-2-%E5%88%A9%E7%94%A8%E6%8E%A7%E5%88%B6%E5%8F%B0%E9%83%A8%E7%BD%B2"><span class="nav-number">3.2.</span> <span class="nav-text">3.2 利用控制台部署</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#3-3-%E8%87%AA%E5%AE%9A%E4%B9%89%E7%9A%84Web%E9%83%A8%E7%BD%B2%E6%96%87%E4%BB%B6"><span class="nav-number">3.3.</span> <span class="nav-text">3.3 自定义的Web部署文件</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#3-4-%E4%BF%AE%E6%94%B9server-xml%E6%96%87%E4%BB%B6%E9%83%A8%E7%BD%B2Web%E5%BA%94%E7%94%A8"><span class="nav-number">3.4.</span> <span class="nav-text">3.4 修改server.xml文件部署Web应用</span></a></li></ol></li></ol></div>
      </section>
      <!--/noindex-->

      <section class="site-overview-wrap sidebar-panel">
        <div class="site-author animated" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image" alt="TANGMONK-MEAT"
      src="https://s1.ax1x.com/2020/09/22/wOscW9.jpg">
  <p class="site-author-name" itemprop="name">TANGMONK-MEAT</p>
  <div class="site-description" itemprop="description">直到这一刻微笑着说话为止，我至少留下了一公升眼泪</div>
</div>
<div class="site-state-wrap animated">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/blog/archives/">
        
          <span class="site-state-item-count">38</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/blog/categories/">
          
        <span class="site-state-item-count">17</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/blog/tags/">
          
        <span class="site-state-item-count">44</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>
  <div class="links-of-author animated">
      <span class="links-of-author-item">
        <a href="https://github.com/TANGMONK-MEAT" title="GitHub → https:&#x2F;&#x2F;github.com&#x2F;TANGMONK-MEAT" rel="noopener" target="_blank"><i class="fab fa-github fa-fw"></i>GitHub</a>
      </span>
      <span class="links-of-author-item">
        <a href="mailto:2950371251@qq.com" title="E-Mail → mailto:2950371251@qq.com" rel="noopener" target="_blank"><i class="fa fa-envelope fa-fw"></i>E-Mail</a>
      </span>
      <span class="links-of-author-item">
        <a href="https://gitee.com/TANGMONK-MEAT" title="Gitee → https:&#x2F;&#x2F;gitee.com&#x2F;TANGMONK-MEAT" rel="noopener" target="_blank"><i class="iconfont icongitee-fill-round fa-fw"></i>Gitee</a>
      </span>
      <span class="links-of-author-item">
        <a href="https://www.leancloud.cn/" title="LeanCloud → https:&#x2F;&#x2F;www.leancloud.cn" rel="noopener" target="_blank"><i class="iconfont iconCloudupload fa-fw"></i>LeanCloud</a>
      </span>
  </div>
  <div class="cc-license animated" itemprop="license">
    <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/zh-CN" class="cc-opacity" rel="noopener" target="_blank"><img src="/blog/images/cc-by-nc-sa.svg" alt="Creative Commons"></a>
  </div>



      </section>
    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </header>

      
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>

  <a href="https://github.com/TANGMONK-MEAT" class="github-corner" title="Follow me on GitHub" aria-label="Follow me on GitHub" rel="noopener" target="_blank"><svg width="80" height="80" viewBox="0 0 250 250" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path></svg></a>

<noscript>
  <div id="noscript-warning">Theme NexT works best with JavaScript enabled</div>
</noscript>


      <div class="main-inner">
        

        <div class="content post posts-expand">
          

    
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://tangmonk-meat.gitee.io/blog/2021/03/19/%E9%85%8D%E7%BD%AETomcat%E7%BD%91%E9%A1%B5%E7%AE%A1%E7%90%86%E8%AE%BF%E9%97%AE/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="https://s1.ax1x.com/2020/09/22/wOscW9.jpg">
      <meta itemprop="name" content="TANGMONK-MEAT">
      <meta itemprop="description" content="直到这一刻微笑着说话为止，我至少留下了一公升眼泪">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="唐僧肉BLOG">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          配置Tomcat网页管理访问 - Tomcat
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2021-03-19 21:16:54" itemprop="dateCreated datePublished" datetime="2021-03-19T21:16:54+08:00">2021-03-19</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2020-09-23 10:27:09" itemprop="dateModified" datetime="2020-09-23T10:27:09+08:00">2020-09-23</time>
              </span>

          
            <span id="/blog/2021/03/19/%E9%85%8D%E7%BD%AETomcat%E7%BD%91%E9%A1%B5%E7%AE%A1%E7%90%86%E8%AE%BF%E9%97%AE/" class="post-meta-item leancloud_visitors" data-flag-title="配置Tomcat网页管理访问 - Tomcat" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
            <span class="post-meta-item" title="阅读次数" id="busuanzi_container_page_pv" style="display: none;">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span id="busuanzi_value_page_pv"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="far fa-comment"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/blog/2021/03/19/%E9%85%8D%E7%BD%AETomcat%E7%BD%91%E9%A1%B5%E7%AE%A1%E7%90%86%E8%AE%BF%E9%97%AE/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/blog/2021/03/19/%E9%85%8D%E7%BD%AETomcat%E7%BD%91%E9%A1%B5%E7%AE%A1%E7%90%86%E8%AE%BF%E9%97%AE/" itemprop="commentCount"></span>
    </a>
  </span>
  
  <br>
            <span class="post-meta-item" title="本文字数">
              <span class="post-meta-item-icon">
                <i class="far fa-file-word"></i>
              </span>
                <span class="post-meta-item-text">本文字数：</span>
              <span>3.5k</span>
            </span>
            <span class="post-meta-item" title="阅读时长">
              <span class="post-meta-item-icon">
                <i class="far fa-clock"></i>
              </span>
                <span class="post-meta-item-text">阅读时长 &asymp;</span>
              <span>3 分钟</span>
            </span>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <h1 id="1-前言"><a href="#1-前言" class="headerlink" title="1 前言"></a>1 前言</h1><p>我们都知道 Tomcat 可以部署 war包和静态资源，一般都是放在<code>webapps</code>下面。但是我们还应该知道，有个界面会帮我们去完成这个操作的，当然这个界面一般是不开放的，自己用的时候可以开放出来。</p>
<a id="more"></a>

<ul>
<li><p>开启 Tomcat服务（直接到tomcat服务器的bin目录下运行startup.sh脚本）；</p>
</li>
<li><p>浏览器访问 <a target="_blank" rel="noopener" href="http://localhost:8080/">http://localhost:8080</a> ，如图：</p>
</li>
</ul>
<p><img data-src="https://s1.ax1x.com/2020/08/09/aTg3rj.png" alt="aTg3rj.png"></p>
<p>上述就是Tomcat的三个控制台界面的入口按钮，分别是Server Status控制台、Manager App控制台和Host Manager控制台；</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">Server Status 控制台 : 用来监控服务器状态;</span><br><span class="line">Manager App控制台 : 可以部署、监控web应用,因此通常使用Manager控制台即可;</span><br><span class="line">Host Manager控制台 ： Tomcat 的虚拟主机管理</span><br></pre></td></tr></table></figure>

<p>点击任意控制台的按钮，会弹出窗口 让输入用户名密码，你随便输入，反正是进不去，点取消还会报错，如图：</p>
<p><img data-src="https://s1.ax1x.com/2020/08/09/aThxVH.png" alt="aThxVH.png"></p>
<p><strong>大致意思如下：</strong></p>
<p>您没有权限查看此页面（控制台）；</p>
<p>如果尚未更改任何Tomcat的配置文件，请在Tomcat的安装文件中检查文件<code>conf/tomcat-users.xml</code>；</p>
<p>该文件必须包含凭据（登录角色和密码），以便您使用此 Web应用程序（控制台）；</p>
<p>例如，要将<code>manager-gui</code>角色，添加到【用户名为tomcat且密码为s3cret】的用户中，</p>
<p>请将以下内容添加到上面列出的配置文件<code>conf/tomcat-users.xml</code>中:</p>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">role</span> <span class="attr">rolename</span> =<span class="string">“manager-gui”</span> /&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">user</span> <span class="attr">username</span> =<span class="string">“tomcat”</span> <span class="attr">password</span> =<span class="string">“s3cret”</span> <span class="attr">role</span> =<span class="string">“manager-gui”</span> /&gt;</span></span><br></pre></td></tr></table></figure>
<p><strong>请注意</strong>：</p>
<p>从 Tomcat 7 开始，使用管理器应用程序所需的角色已从单个管理器角色更改为以下四个角色，</p>
<p>您将需要分配想要访问的功能所需的角色，如下：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">manager-gui ： 允许访问HTML GUI和状态页面</span><br><span class="line"></span><br><span class="line">manager-script ： 允许访问文本界面和状态页面</span><br><span class="line"></span><br><span class="line">manager-jmx ： 允许访问JMX代理和状态页面</span><br><span class="line"></span><br><span class="line">manager-status ： 仅允许访问状态页面</span><br></pre></td></tr></table></figure>

<p>HTML界面受CSRF保护，但text和JMX界面不受保护。 维护CSRF保护：</p>
<p>具有manager-gui角色的用户不应被授予manager-script 或 manager-jmx角色；</p>
<p>如果通过浏览器访问了文本或jmx接口（例如，由于这些接口是针对非人类的工具而进行测试），则此后<strong>必须关闭浏览器以终止会话</strong>。</p>
<h1 id="2-如何登陆控制台？"><a href="#2-如何登陆控制台？" class="headerlink" title="2 如何登陆控制台？"></a>2 如何登陆控制台？</h1><p>Tomcat默认没有配置任何用户，我们可以打开 <code>conf/tomcat-users.xml</code>文件，通过<strong>user元素</strong>添加用户；</p>
<p>如上所述，我们需要到Tomcat的安装目录下，找到 <code>conf/tomcat-users.xml</code> 配置文件，</p>
<ul>
<li>使用 <code>role</code>元素 添加管理员角色</li>
<li>使用 <code>user</code>元素 添加用户</li>
<li>使用 user元素的<code>roles</code>属性，赋予该用户管理器应用程序所需的角色（可以多个，以逗号分隔），即可</li>
</ul>
<blockquote>
<p>conf / tomcat-users.xml</p>
</blockquote>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">tomcat-users</span> <span class="attr">xmlns</span>=<span class="string">&quot;http://tomcat.apache.org/xml&quot;</span> <span class="attr">xmlns:xsi</span>=<span class="string">&quot;http://www.w3.org/2001/XMLSchema-instance&quot;</span> <span class="attr">xsi:schemaLocation</span>=<span class="string">&quot;http://tomcat.apache.org/xml tomcat-users.xsd&quot;</span> <span class="attr">version</span>=<span class="string">&quot;1.0&quot;</span>&gt;</span></span><br><span class="line"><span class="comment">&lt;!-- </span></span><br><span class="line"><span class="comment">  &lt;role rolename=&quot;tomcat&quot;/&gt;</span></span><br><span class="line"><span class="comment">  &lt;role rolename=&quot;role1&quot;/&gt;</span></span><br><span class="line"><span class="comment">  &lt;user username=&quot;both&quot; password=&quot;&lt;must-be-changed&gt;&quot; roles=&quot;tomcat,role1&quot;/&gt;</span></span><br><span class="line"><span class="comment">  &lt;user username=&quot;tomcat&quot; password=&quot;&lt;must-be-changed&gt;&quot; roles=&quot;tomcat&quot;/&gt;</span></span><br><span class="line"><span class="comment">  &lt;user username=&quot;role1&quot; password=&quot;&lt;must-be-changed&gt;&quot; roles=&quot;role1&quot;/&gt;</span></span><br><span class="line"><span class="comment"> --&gt;</span></span><br><span class="line">    <span class="comment">&lt;!--  manager 角色   --&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">role</span> <span class="attr">rolename</span>=<span class="string">&quot;manager-gui&quot;</span>/&gt;</span></span><br><span class="line">    <span class="comment">&lt;!-- 被赋予该角色的用户 --&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">user</span> <span class="attr">username</span>=<span class="string">&quot;tomcat&quot;</span> <span class="attr">password</span>=<span class="string">&quot;s3cret&quot;</span> <span class="attr">roles</span>=<span class="string">&quot;manager-gui&quot;</span>/&gt;</span> </span><br><span class="line"><span class="tag">&lt;/<span class="name">tomcat-users</span>&gt;</span></span><br></pre></td></tr></table></figure>

<p>上面配置文件就增加了一个 <code>manager-gui</code>用户;</p>
<p>我们登陆 【控制台】 需要不同的角色，可以参考<code>/webapps/manager/WEB-INF/web.xml</code>文件知道；</p>
<p>Tomcat支持的管理员角色只有四个，如下：</p>
<blockquote>
<p>webapps / manager / WEB-INF / web.xml</p>
</blockquote>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">security-constraint</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">web-resource-collection</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">web-resource-name</span>&gt;</span>Status interface<span class="tag">&lt;/<span class="name">web-resource-name</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">url-pattern</span>&gt;</span>/status/*<span class="tag">&lt;/<span class="name">url-pattern</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">web-resource-collection</span>&gt;</span></span><br><span class="line">    <span class="comment">&lt;!-- 管理员角色 --&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">auth-constraint</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">role-name</span>&gt;</span>manager-gui<span class="tag">&lt;/<span class="name">role-name</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">role-name</span>&gt;</span>manager-script<span class="tag">&lt;/<span class="name">role-name</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">role-name</span>&gt;</span>manager-jmx<span class="tag">&lt;/<span class="name">role-name</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">role-name</span>&gt;</span>manager-status<span class="tag">&lt;/<span class="name">role-name</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">auth-constraint</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">security-constraint</span>&gt;</span></span><br></pre></td></tr></table></figure>

<p><strong>注意：</strong><br>配置了 <code>manager-gui</code>角色的用户，不可以再被授予 <code>manager-script</code> 或 <code>manager-jmx</code>角色。</p>
<p>点击 <code>Manager App</code> 按钮，成功登录之后，可以看到，如图：</p>
<p><a target="_blank" rel="noopener" href="https://imgchr.com/i/aT7eCd"><img data-src="https://s1.ax1x.com/2020/08/09/aT7eCd.md.png" alt="aT7eCd.md.png"></a></p>
<h1 id="3-部署web应用"><a href="#3-部署web应用" class="headerlink" title="3 部署web应用"></a>3 部署web应用</h1><p>部署web应用的方式主要有以下几种：</p>
<ul>
<li>利用tomcat的自动部署</li>
<li>利用控制台部署</li>
<li>增加自定义的Web部署文件</li>
<li>修改server.xml文件部署Web应用</li>
</ul>
<h2 id="3-1-利用tomcat的自动部署"><a href="#3-1-利用tomcat的自动部署" class="headerlink" title="3.1 利用tomcat的自动部署"></a>3.1 利用tomcat的自动部署</h2><p>利用tomcat的自动部署是最简单，最常用的方式，只需要将一个web应用复制到Tomcat的webapps目录下，就可以，系统就会把该应用部署到tomcat中。</p>
<h2 id="3-2-利用控制台部署"><a href="#3-2-利用控制台部署" class="headerlink" title="3.2 利用控制台部署"></a>3.2 利用控制台部署</h2><p>在web应用的控制台，按如下两种方式：</p>
<p><img data-src="https://s1.ax1x.com/2020/08/09/aT7raF.png" alt="aT7raF.png"></p>
<p>点击Deploy按钮，将会看到Tomcat的webapps目录下多了一个名为aaa的文件夹，该文件夹的内容就是部署的web应用。这表明：当利用控制台部署应用时，实际依然是利用tomcat的自动部署。</p>
<h2 id="3-3-自定义的Web部署文件"><a href="#3-3-自定义的Web部署文件" class="headerlink" title="3.3 自定义的Web部署文件"></a>3.3 自定义的Web部署文件</h2><p>操作步骤：</p>
<ol>
<li>在 <code>conf/Catalina/localhost</code> 目录下，新建一个任意名字的xml文件</li>
<li>该文件就是部署web应用的配置文件</li>
<li>该文件的文件名，将作为web应用的虚拟路径</li>
</ol>
<p><strong>例如</strong>： 在 <code>conf/Catalina/localhost</code> 目录下，增加一个<strong>test.xml</strong>文件，该文件内容如下:</p>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">Context</span> <span class="attr">docBase</span>=<span class="string">&quot;Web应用在磁盘的绝对路径&quot;</span> <span class="attr">debug</span>=<span class="string">&quot;0&quot;</span> <span class="attr">privileged</span>=<span class="string">&quot;true&quot;</span>/&gt;</span></span><br></pre></td></tr></table></figure>

<p>再次启动Tomcat服务，Tomcat会把该配置文件路径下的web应用，部署到Tomcat。</p>
<h2 id="3-4-修改server-xml文件部署Web应用"><a href="#3-4-修改server-xml文件部署Web应用" class="headerlink" title="3.4 修改server.xml文件部署Web应用"></a>3.4 修改server.xml文件部署Web应用</h2><p>这种方式是修改 <code>conf/server.xml</code> 文件，修改该文件可能破坏Tomcat的系统文件，不建议采用，这里就不提了。</p>

    </div>

     <!-- 文章结束表示语-->
    <div>
      
        <div>
    
        <div style="text-align:center;color: #ccc;font-size:14px;">-------------本文结束<i class="fa fa-paw"></i>感谢您的阅读-------------</div>
    
</div>
      
    </div>

    
    
    
        

<div>
<ul class="post-copyright">
  <li class="post-copyright-author">
    <strong>本文作者： </strong>TANGMONK-MEAT
  </li>
  <li class="post-copyright-link">
    <strong>本文链接：</strong>
    <a href="https://tangmonk-meat.gitee.io/blog/2021/03/19/%E9%85%8D%E7%BD%AETomcat%E7%BD%91%E9%A1%B5%E7%AE%A1%E7%90%86%E8%AE%BF%E9%97%AE/" title="配置Tomcat网页管理访问 - Tomcat">https://tangmonk-meat.gitee.io/blog/2021/03/19/配置Tomcat网页管理访问/</a>
  </li>
  <li class="post-copyright-license">
    <strong>版权声明： </strong>本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/zh-CN" rel="noopener" target="_blank"><i class="fab fa-fw fa-creative-commons"></i>BY-NC-SA</a> 许可协议。转载请注明出处！
  </li>
</ul>
</div>


      <footer class="post-footer">
          <div class="post-tags">
              <a href="/blog/tags/java/" rel="tag"><i class="fa fa-tag"></i> java</a>
              <a href="/blog/tags/Tomcat/" rel="tag"><i class="fa fa-tag"></i> Tomcat</a>
          </div>

        


        
    <div class="post-nav">
      <div class="post-nav-item">
    <a href="/blog/2021/03/19/%E5%BC%80%E5%90%AFDruid%E7%9B%91%E6%8E%A7%E7%BB%9F%E8%AE%A1%E5%8A%9F%E8%83%BD(SQL%E7%9B%91%E6%8E%A7%E3%80%81%E6%85%A2SQL%E8%AE%B0%E5%BD%95%E3%80%81Spring%E7%9B%91%E6%8E%A7%E3%80%81%E5%8E%BB%E5%B9%BF%E5%91%8A)/" rel="prev" title="开启Druid监控统计功能(SQL监控、慢SQL记录、Spring监控、去广告)">
      <i class="fa fa-chevron-left"></i> 开启Druid监控统计功能(SQL监控、慢SQL记录、Spring监控、去广告)
    </a></div>
      <div class="post-nav-item">
    <a href="/blog/2021/03/19/eclipse%E8%A6%81%E6%B1%82%E7%9A%84jre%E5%92%8C%E6%9C%AC%E6%9C%BA%E7%9A%84jre%E7%89%88%E6%9C%AC%E5%86%B2%E7%AA%81/" rel="next" title="eclipse要求的jre和本机的jre版本冲突">
      eclipse要求的jre和本机的jre版本冲突 <i class="fa fa-chevron-right"></i>
    </a></div>
    </div>
      </footer>
    
  </article>
  
  
  



        </div>
        
    <div class="comments" id="valine-comments"></div>

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2021</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">TANGMONK-MEAT</span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item-icon">
      <i class="fa fa-chart-area"></i>
    </span>
      <span class="post-meta-item-text">站点总字数：</span>
    <span title="站点总字数">148k</span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item-icon">
      <i class="fa fa-coffee"></i>
    </span>
      <span class="post-meta-item-text">站点阅读时长 &asymp;</span>
    <span title="站点阅读时长">2:15</span>
</div>

<!--
-->

<!--<div>
<span id="busuanzi_container_site_pv">
    本站总访问量<span id="busuanzi_value_site_pv"></span>次
</span> 
 <span class="post-meta-divider">|</span> 
 <span class="post-meta-item-icon">
<span id="busuanzi_container_site_uv">
  本站访客数<span id="busuanzi_value_site_uv"></span>人次
</span>
</div> 

-->




        
<div class="busuanzi-count">
  <script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
    <span class="post-meta-item" id="busuanzi_container_site_uv" style="display: none;">
      <span class="post-meta-item-icon">
        <i class="fa fa-user"></i>
      </span>
      <span class="site-uv" title="总访客量">
        <span id="busuanzi_value_site_uv"></span>
      </span>
    </span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item" id="busuanzi_container_site_pv" style="display: none;">
      <span class="post-meta-item-icon">
        <i class="fa fa-eye"></i>
      </span>
      <span class="site-pv" title="总访问量">
        <span id="busuanzi_value_site_pv"></span>
      </span>
    </span>
</div>








      </div>
    </footer>
  </div>

  
  <script src="/blog/lib/anime.min.js"></script>
  <script src="//cdn.jsdelivr.net/npm/jquery@3/dist/jquery.min.js"></script>
  <script src="//cdn.jsdelivr.net/npm/@fancyapps/fancybox@3/dist/jquery.fancybox.min.js"></script>
  <script src="//cdn.jsdelivr.net/npm/lozad@1/dist/lozad.min.js"></script>

<script src="/blog/js/utils.js"></script>

<script src="/blog/js/motion.js"></script>


<script src="/blog/js/schemes/muse.js"></script>


<script src="/blog/js/next-boot.js"></script>


  
  <script>
    (function(){
      var bp = document.createElement('script');
      var curProtocol = window.location.protocol.split(':')[0];
      bp.src = (curProtocol === 'https') ? 'https://zz.bdstatic.com/linksubmit/push.js' : 'http://push.zhanzhang.baidu.com/push.js';
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(bp, s);
    })();
  </script>




  
<script src="/blog/js/local-search.js"></script>













  

  


<script>
NexT.utils.loadComments('#valine-comments', () => {
  NexT.utils.getScript('//cdn.jsdelivr.net/npm/valine@1/dist/Valine.min.js', () => {
    new Valine(Object.assign({
      el  : '#valine-comments',
      path: location.pathname,
    }, {"enable":true,"appId":"dkMV7sEQR97E6CWI5jduGKf3-gzGzoHsz","appKey":"JQfXJ0ELtfNma5bdMQk0vgwX","placeholder":"ヾﾉ≧∀≦)o来啊，快活啊!","avatar":"mm","meta":["nick","mail"],"pageSize":10,"language":"zh-cn","visitor":true,"comment_count":true,"recordIP":true,"serverURLs":null,"enableQQ":false,"requiredFields":[]}
    ));
  }, window.Valine);
});
</script>

</body>
</html>
